/*
 * @Author: fanjs
 * @Date: 2025-03-18 11:14:19
 * @Description: 验证工具
 */

// 手机号校验
export function isPhone(str: string) {
  return /^1[3456789]\d{9}$/.test(str);
}

// 密码校验
export function isPassword(str: string) {
  return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,}$/.test(str)
}

// 身份证
export function isIdCard(str: string) {
  return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(str);
}

// 邮箱
export function isEmail(str: string) {
  return /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(str);
}

export function isUrl(str: string) {
  return /^(https?|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/.test(
    str
  );
}
